function getTitle (vm) {
  const { title } = vm.$options
  if (title) {
    return typeof title === 'function'
      ? title.call(vm)
      : title
  }
}

export default {
  created () {
    const title = getTitle(this)
    if (title) {
      document.title = title
      this.$store.state.curTitle.title = document.title
    }
  },
  updated () {
    if (this.$options.$_page_title) {
      document.title = this.$options.$_page_title
      // this.$store.state.title = document.title
    }
  }
}
